package com.ruoyi.web.controller.market.source;

import java.util.List;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.SourceMemberDataInfoTemp;
import com.ruoyi.source.service.ISourceMemberDataInfoTempService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.wapper.SourceMemberDataInfoTempWapper;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 线索用户资质信息Controller
 * 
 * @author ruoyi
 * @date 2024-08-22
 */
@Controller
@RequestMapping("/source/dataInfoTemp")
public class SourceMemberDataInfoTempController extends BaseController
{
    private String prefix = "source/dataInfoTemp";

    @Autowired
    private ISourceMemberDataInfoTempService sourceMemberDataInfoTempService;

    @RequiresPermissions("source:dataInfoTemp:list")
    @GetMapping()
    public String dataInfoTemp()
    {
        return prefix + "/dataInfoTemp";
    }

    /**
     * 查询线索用户资质信息列表
     */
    @RequiresPermissions("source:dataInfoTemp:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SourceMemberDataInfoTemp sourceMemberDataInfoTemp)
    {
        startPage();
        List<Map<String, Object>> mapList = sourceMemberDataInfoTempService.selectSourceMemberDataInfoTempListMap(sourceMemberDataInfoTemp);
        mapList = new SourceMemberDataInfoTempWapper(mapList).wrap();
        return getDataTable(mapList);
    }

    /**
     * 导出线索用户资质信息列表
     */
    @RequiresPermissions("source:dataInfoTemp:export")
    @Log(title = "线索用户资质信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SourceMemberDataInfoTemp sourceMemberDataInfoTemp)
    {
        List<SourceMemberDataInfoTemp> list = sourceMemberDataInfoTempService.selectSourceMemberDataInfoTempList(sourceMemberDataInfoTemp);
        ExcelUtil<SourceMemberDataInfoTemp> util = new ExcelUtil<SourceMemberDataInfoTemp>(SourceMemberDataInfoTemp.class);
        return util.exportExcel(list, "线索用户资质信息数据");
    }

    /**
     * 新增线索用户资质信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存线索用户资质信息
     */
    @RequiresPermissions("source:dataInfoTemp:add")
    @Log(title = "线索用户资质信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SourceMemberDataInfoTemp sourceMemberDataInfoTemp)
    {
        return toAjax(sourceMemberDataInfoTempService.insertSourceMemberDataInfoTemp(sourceMemberDataInfoTemp));
    }

    /**
     * 修改线索用户资质信息
     */
    @RequiresPermissions("source:dataInfoTemp:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SourceMemberDataInfoTemp sourceMemberDataInfoTemp = sourceMemberDataInfoTempService.selectSourceMemberDataInfoTempById(id);
        mmap.put("sourceMemberDataInfoTemp", sourceMemberDataInfoTemp);
        return prefix + "/edit";
    }

    /**
     * 修改保存线索用户资质信息
     */
    @RequiresPermissions("source:dataInfoTemp:edit")
    @Log(title = "线索用户资质信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SourceMemberDataInfoTemp sourceMemberDataInfoTemp)
    {
        return toAjax(sourceMemberDataInfoTempService.updateSourceMemberDataInfoTemp(sourceMemberDataInfoTemp));
    }

    /**
     * 删除线索用户资质信息
     */
    @RequiresPermissions("source:dataInfoTemp:remove")
    @Log(title = "线索用户资质信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sourceMemberDataInfoTempService.deleteSourceMemberDataInfoTempByIds(ids));
    }
}
